#include "workmanager.h"

void WorkManager::JobToRemote(Job job)
{
	m_remote_mutex.lock();
	m_to_remote.push(job);
	m_remote_mutex.unlock();
}
void WorkManager::JobToLocal(Job job)
{
	m_local_mutex.lock();
	m_to_local.push(job);
	m_local_mutex.unlock();
}

bool WorkManager::GetJobToRemote(Job& job)
{
	m_remote_mutex.lock();
	
	if (!m_to_remote.empty())
	{
		job = m_to_remote.front();
		m_to_remote.pop();
		m_remote_mutex.unlock();
		return true;
	}

	m_remote_mutex.unlock();
	return false;
}

bool WorkManager::GetJobToLocal(Job& job)
{
	m_local_mutex.lock();
	
	if (!m_to_local.empty())
	{
		job = m_to_local.front();
		m_to_local.pop();
		m_local_mutex.unlock();
		return true;
	}

	m_local_mutex.unlock();
	return false;
}